package com.hyt.it.ogt.kq.service.gov.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyt.core.base.BaseServiceImpl;
import com.hyt.it.ogt.kq.service.gov.mapper.BackUpMapper;
import com.hyt.it.ogt.kq.service.gov.mapper.BehaviorAnalysisMapper;
import com.hyt.it.ogt.kq.service.gov.model.entity.BackUp;
import com.hyt.it.ogt.kq.service.gov.model.entity.BehaviorAnalysis;
import com.hyt.it.ogt.kq.service.gov.model.param.BackUpParam;
import com.hyt.it.ogt.kq.service.gov.model.vo.BackUpPageVo;
import com.hyt.it.ogt.kq.service.gov.model.vo.BehaviorAnalysisPageVo;
import com.hyt.it.ogt.kq.service.gov.service.IBackUpService;
import com.hyt.it.ogt.kq.service.gov.service.IBehaviorAnalysisService;
import com.hyt.model.PageParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Service
public class BackUpImpl extends BaseServiceImpl<BackUpMapper, BackUp> implements IBackUpService {
    @Resource
    BackUpMapper mapper;

    @Override
    public Page<BackUpPageVo> queryPage(PageParam<BackUpPageVo> pageParam, BackUpParam param) {
        Page<BackUpPageVo> page = mapper.queryPage(pageParam,param);
        List<BackUpPageVo> records = page.getRecords();
        if (records.isEmpty()) {
            return page;
        }
        records.stream().forEach(pageVO -> {
            if(1 == pageVO.getState()){
                pageVO.setStateName("开始备份");
            }else {
                pageVO.setStateName("已备份");
            }
        });
        return page;
    }
}
